#!/usr/bin/env python
# -*- coding: utf-8 -*-

class Cal:
    def add(self, a, b):
        return a + b

    def sub(self, a, b):
        return a - b

    def mul(self, a, b):
        return a * b

    def div(self, a, b):
        return a / b


import unittest


class TestCal(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        cls.cal = Cal()

    def test_add01(self):
        result = self.cal.add(1, 1)
        self.assertEqual(result, 2)

    def test_add02(self):
        result = self.cal.add(1.123, 3.1415)
        self.assertEqual(result, 4.2645)

    def test_add03(self):
        result = self.cal.add(6, -1)
        self.assertEqual(result, 5)


# Testsuite类是用来对测试用例进行组合分类, 通常称为测试套件.
# 我们将不同位置的测试用例集合到一个测试套件内, 并且利用run方法来执行
if __name__ == '__main__':
    suite = unittest.TestSuite()
    suite.addTest(TestCal('test_add01'))
    # addTests方法的参数, 必须是可迭代的数据类型: 列表, 元组
    suite.addTests([TestCal('test_add02'), TestCal('test_add03')])
    # suite.addTests((TestCal('test_add02'), TestCal('test_add03')))
    runner = unittest.TextTestRunner()
    runner.run(suite)
